#include "AVRGlobal.h"
#include "../../../bit/bit.h"

void setGlobalInterrupt(unsigned char flag)
{
	SREG = SetBit(SREG, 7, flag);
}

void setBitCopyStorage(unsigned char flag)
{
	SREG = SetBit(SREG, 6, flag);
}

unsigned char getBitCopyStorage()
{
	return GetBit(SREG, 6);
}

unsigned char getHalfCarryFlag()
{
	return GetBit(SREG, 5);
}

unsigned char getSignBit()
{
	return GetBit(SREG, 4);
}

unsigned char getTwosComplementOverflowFlag()
{
	return GetBit(SREG, 3);
}

unsigned char getNegativeFlag()
{
	return GetBit(SREG, 2);
}

unsigned char getZeroFlag()
{
	return GetBit(SREG, 1);
}


unsigned char getCarryFlag()
{
	return GetBit(SREG, 0);
}

unsigned long getStackPointer()
{
	unsigned long upperHalf = 0x00FF & SPH;
	unsigned long lowerHalf = 0x00FF & SPL;
	unsigned long temp = ((upperHalf<<8) & 0xFF00) | lowerHalf;
	return temp; //gets the stack pointer.
}

void setStackPointer(unsigned long pointer)
{
	unsigned long upperHalf = 0xFF00 & pointer;
	unsigned long lowerHalf = 0x00FF & pointer;
	unsigned char upper2 = (unsigned char) (upperHalf >> 8);
	unsigned char lower2 = (unsigned char) lowerHalf;
	SPH = upper2;
	SPL = lower2;
}







